package com.elmcode.study.controller;

import com.elmcode.study.service.UserService;
import com.elmcode.study.to.UserDTO;
import com.elmcode.study.utils.Result;
import com.elmcode.study.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "用户接口")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping
    @ApiOperation("编辑用户接口")
    public Result edit(@RequestBody UserDTO userDTO){

        Result result = new Result<>();
        result.setMsg("编辑成功");
        result.setData(userDTO);
        return result;
    }


    @GetMapping("/list")
    @ApiOperation("查找用户接口")
    public Result list(){

        Result result = new Result<>();
        List<UserVo> voList = userService.list();
        result.setMsg("查找成功");
        result.setData(voList);
        return result;
    }
}